﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp5
{
    public partial class Form4 : Form
    {
       private int id;

        public Form4()
        {
            InitializeComponent();
        }
        //添加
        private void button1_Click(object sender, EventArgs e)
        {
            var SalaryString = textBox2.Text.ToString();

            var ManagerIdString = textBox3.Text.ToString();

            var title = textBox1.Text;

            var author = textBox2.Text;

            if (id > 0)
            {
                string conSting = string.Format("update Articles set Title = '{0}',Author = '{1}' where Id = {2}", id, title, author);

                var sql = DbHelper.AddOrEditSave(conSting);

                if (sql == 1)
                {
                    MessageBox.Show("我们成功啦!", "夜夜夜夜 提示");

                    this.DialogResult = DialogResult.Yes;

                    this.Close();
                }
            }
            else
            {
                string cmdSting = string.Format("insert into Articles(Title, Author)values('{0}', '{1}')", title, author);

                var ber = DbHelper.AddOrEditSave(cmdSting);

                if (ber == 1)
                {
                    MessageBox.Show("添加成功", "来自亲爱的提示");

                    this.DialogResult = DialogResult.Yes;

                    this.Close();
                }
            }
        }
        
         //取消
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close ();
        }

        private void Form4_Load(object sender, EventArgs e)
        {

        }
    }   
}
